#ifndef __MEAS_DEVICE_H_
#define __MEAS_DEVICE_H_

#include <stdint.h>
#include "soc/soc_caps.h"
#include "esp_adc/adc_oneshot.h"
#include "esp_adc/adc_cali.h"
#define TAB_LENGTH 200
class MeasDevice
{
private:
    uint16_t Temp2Res_Tab[TAB_LENGTH];
    adc_oneshot_unit_handle_t adc_handle;

    adc_cali_handle_t vbus_cali_handle;
    adc_cali_handle_t mt_out_cali_handle;
    adc_cali_handle_t ntc_cali_handle;
    uint32_t vbus_adc_channel;
    uint32_t mt_out_adc_channel;
    uint32_t ntc_adc_channel;
public:
    MeasDevice(void) {}
    ~MeasDevice() {}

    void init(uint32_t _vbus_adc_ch, uint32_t _mt_out_adc_ch, uint32_t _ntc_adc_ch);

    float get_vbus_volt(void);

    float get_board_temp(void);

    float get_mt_out(void);

    void destroy(void);

private:
    bool adc_cali_init(adc_unit_t unit, adc_channel_t channel, adc_atten_t atten, adc_cali_handle_t *out_handle);
    float temper_get(int voltage);
};


#endif // __MEAS_DEVICE_H_

